//
//  DevelopmentModel.swift
//
//  Created by Icy on 2017/3/25
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

 public class DevelopmentModel: ModelProtocol {

    // MARK: Declaration for string constants to be used to decode and also serialize.
	internal let kDevelopmentCommunitiesKey: String = "communities"
	internal let kDevelopmentAddressKey: String = "address"


    // MARK: 属性
	 public var communities: [CommunitiesModel]
	 public var address: String


    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
   public required  init?(json: JSON) {
		communities = []
		if let items = json[kDevelopmentCommunitiesKey].array {
			for item in items {
				if let communitiesModel = CommunitiesModel(json: item){
								communities.append(communitiesModel)
						}
			}
		}
		address = json[kDevelopmentAddressKey].stringValue

    }


    /**
    Generates description of the object in the form of a NSDictionary.
    - returns: A Key value pair containing all valid values in the object.
    */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {

        var dictionary: [String : AnyObject ] = [ : ]
			var temp: [AnyObject] = []
			for item in communities {
				temp.append(item.dictionaryRepresentation() as AnyObject)
			}
			dictionary.updateValue(temp as AnyObject, forKey: kDevelopmentCommunitiesKey)
		

			dictionary.updateValue(address as AnyObject as AnyObject, forKey: kDevelopmentAddressKey)
		

        return dictionary
    }


}
